<%= render 'spree/admin/shared/sub_menu/configuration' %>

<% content_for :page_title do %>
  <%= Spree.t(:recurring) %>
<% end %>

<% content_for :page_actions do %>
  <%= button_link_to Spree.t(:new_recurring), new_admin_recurring_url, :icon => 'plus', class: "btn-success", :id => 'admin_new_recurring_link' %>
<% end if can? :create, Spree::Recurring %>

<% if @recurrings.any? %>
  <table class="table" id='listing_recurrings'>
    <thead>
      <tr data-hook="admin_payment_methods_index_headers">
        <th><%= Spree.t(:name) %></th>
        <th><%= Spree.t(:provider) %></th>
        <th><%= Spree.t(:active) %></th>
        <th data-hook="admin_payment_methods_index_header_actions" class="actions actions-2 text-right"></th>
      </tr>
    </thead>
    <tbody>
      <% @recurrings.each do |recurring|%>
        <tr id="<%= spree_dom_id recurring %>" data-hook="admin_recurrings_index_rows" class="<%= cycle('odd', 'even')%>">
          <td><%= recurring.name %></td>
          <td><%= recurring.class.display_name %></td>
          <td><%= recurring.active ? Spree.t(:say_yes) : Spree.t(:say_no) %></td>
          <td data-hook="admin_recurrings_index_row_actions" class="actions actions-2 text-right">
            <%= link_to_edit_url edit_admin_recurring_url(recurring), :no_text => true %>
            <%= link_to_delete recurring, url: admin_recurring_url(recurring), :no_text => true  %>
          </td>
        </tr>
      <% end %>
    </tbody>
  </table>
<% else %>
  <div class="alert alert-info no-objects-found">
    <%= Spree.t(:no_resource_found, resource: I18n.t(:other, scope: 'activerecord.models.spree/recurring')) %>,
    <%= link_to Spree.t(:add_one), spree.new_admin_recurring_url if can? :create, Spree::Recurring %>!
  </div>
<% end %>